<template>
    <div class="pt44">
        <dl class="plr15">
            <dd>
                <div class="d_title">产品名称</div>
                <div class="d_content">{{ goodsName }}</div>
            </dd>
            <dd>
                <div class="d_title">订单号</div>
                <div class="d_content">{{ orderId }}</div>
            </dd>
            <dd>
                <div class="d_title">借款日期</div>
                <div class="d_content">{{ londDate }}</div>
            </dd>
            <dd>
                <div class="d_title">申请人姓名</div>
                <div class="d_content">{{ applyName }}</div>
            </dd>
            <dd>
                <div class="d_title">借款本金</div>
                <div class="d_content">{{ loanMoney }}元</div>
            </dd>
            <dd>
                <div class="d_title">信用卡号</div>
                <div class="d_content">{{ cardId }}</div>
            </dd>
            <dd>
                <div class="d_title">交易状态</div>
                <div class="d_content">{{ state }}</div>
            </dd>
            <dd v-show="londDays">
                <div class="d_title">借款时长</div>
                <div class="d_content">{{ londDays }}天</div>
            </dd>
<!--             <dd v-if="repayType != ''">
    <div class="d_title">还款方式</div>
    <div class="d_content">{{ repayType }}</div>
</dd>
<dd v-if="repayCardId != ''">
    <div class="d_title">还款卡号</div>
    <div class="d_content">{{ repayCardId }}</div>
</dd> -->
            <dd v-if="remark != ''">
                <div class="d_title">失败原因</div>
                <div class="d_content">{{ remark }}</div>
            </dd>
        </dl>
    </div>
</template>

<script>
var cm = require("../components/common.js");
export default  {
    name: 'orderDetails',  // 组件贷款订单详情
    data () {  // 数据
        return {
            msg: 'orderDetails',
            applyName:"",
            loanMoney:"",
            cardId:"",
            londDate:"",
            state:"",
            londDays:"",
            londInterest:"",
            repayType:"",
            repayCardId:"",
            remark:"",
            goodsName:"",
            orderId:""

        }
    },
    methods:{ // 自定义方法，可对data进行处理
        init(){
            this.applyName="";
            this.loanMoney="";
            this.cardId="";
            this.londDate="";
            this.state="";
            this.londDays="";
            this.londInterest="";
            this.repayType="";
            this.repayCardId="";
            this.remark="";
        },
        dealData(arecrd){
            var statemsgMap = {
                "00":"已还款",
                "01":"未还款",
                "02":"失败"
            };
            this.applyName = arecrd.cuast_name;
            this.loanMoney = cm.comdify(parseFloat(arecrd.goods_Amount).toFixed(2));
            this.cardId = arecrd.credit_Card_No
            this.londDate = cm.getDateStrFormate1(arecrd.trans_date,"second");
            this.orderId = arecrd.order_id;
            this.goodsName = "小通帮你借";
            if(arecrd.channal_no == "02"){
                this.goodsName = "小通帮你延";
            }
            if(arecrd.repay_state == "01"){
                this.state = "已还款";
                if(arecrd.repayType == "01"){
                    this.repayType = "主动还款";
                }else{
                    this.repayType = "被动还款";
                }
                this.londDays = arecrd.borrow_days;
                this.repayCardId = arecrd.repayCard;
            }else{
                if(arecrd.trans_status == "A1"){
                    this.state = "交易成功";
                    this.londDays = Math.ceil(cm.DateDiff(new Date(this.londDate.replace(/"-"/g,"/")),this.$store.state.nowDate))
                }else if(arecrd.trans_status == "A2"){
                    this.state = "交易失败";
                    this.remark = arecrd.nt;
                }
            }

            this.londInterest = cm.comdify(parseFloat(arecrd.borrowAmt).toFixed(2));

        },
    },
    beforeMount:function  () {
        this.$store.commit('setNowDate');
        this.init();
//        this.dealData(this.$store.state.detailItem)
        var lrParaments = {
            bizLicNo:this.$store.state.loginName,
            loginName: this.$store.state.loginName,
            token: this.$store.state.token,
            loginType: this.$store.state.loginType,
            openid: this.$store.state.openid,
            prdtNo:"0301",
            type:1,
            trans_seq:this.$store.state.detailItem.trans_seq  // 94
        }
        var _this = this;
        $.post(XtsdCashierTradeServlet, lrParaments, function(lrdata) {
            console.dir(lrdata);
            if(lrdata.xtsd_trans_response && lrdata.xtsd_trans_response.resp_code== "0000" && lrdata.xtsd_trans_response.trans_info_arrays && lrdata.xtsd_trans_response.trans_info_arrays.trans_info){
                _this.dealData(lrdata.xtsd_trans_response.trans_info_arrays.trans_info[0]);


            }
        });
    }
}
</script>

<style lang='scss' scoped>
dl{
    background-color: #fff;
    padding-top: 10px 0;
    line-height: 36px;
    dd{
        height: 36px;
    }
}
.d_title{
    display: inline-block;
    float: left;
    width: 100px;
}
</style>
